//
//  WindowViewProtocol.swift
//  huaya-jisu
//
//  Created by MK on 2021/10/23.
//  Copyright © 2021 taolang. All rights reserved.
//

import UIKit

protocol WindowViewProtocol {
    
}

extension WindowViewProtocol where Self : UIView {
    func showOnWindow(){
        self.alpha = 0
        UIApplication.shared.keyWindow?.addSubview(self)
        UIView.animate(withDuration: 0.3) {
            self.alpha = 1
        }
    }
    
    func removeFromWindow(){
        UIView.animate(withDuration: 0.3) {
            self.alpha = 0
        } completion: { _ in
            self.removeFromSuperview()
        }
    }
}
